home *** CD-ROM | disk | FTP | other *** search
/ Language/OS - Multiplatform Resource Library / LANGUAGE OS.iso / oper_sys / kerberos / pc / krb_libk.lha / Lib / KRB / SAVECRED.C < prev    next >
Encoding:
C/C++ Source or Header  |  1991-05-31  |  1.9 KB  |  56 lines

  1. /*
  2.  * $Source: /mit/kerberos/src/lib/krb/RCS/save_credentials.c,v $
  3.  * $Author: jtkohl $
  4.  *
  5.  * Copyright 1985, 1986, 1987, 1988 by the Massachusetts Institute
  6.  * of Technology.
  7.  *
  8.  * For copying and distribution information, please see the file
  9.  * <mit-copyright.h>.
  10.  */
  11.  
  12. #ifndef lint
  13. static char *rcsid_save_credentials_c =
  14. "$Header: save_credentials.c,v 4.9 89/05/31 17:45:43 jtkohl Exp $";
  15. #endif /* lint */
  16.  
  17. #include <mit_copy.h>
  18. #include <stdio.h>
  19. #include <krb.h>
  20.  
  21. /*
  22.  * This routine takes a ticket and associated info and calls
  23.  * tf_save_cred() to store them in the ticket cache.  The peer
  24.  * routine for extracting a ticket and associated info from the
  25.  * ticket cache is krb_get_cred().  When changes are made to
  26.  * this routine, the corresponding changes should be made
  27.  * in krb_get_cred() as well.
  28.  *
  29.  * Returns KSUCCESS if all goes well, otherwise an error returned
  30.  * by the tf_init() or tf_save_cred() routines.
  31.  */
  32.  
  33. save_credentials(service, instance, realm, session, lifetime, kvno,
  34.                  ticket, issue_date)
  35.     char *service;              /* Service name */
  36.     char *instance;             /* Instance */
  37.     char *realm;                /* Auth domain */
  38.     C_Block session;            /* Session key */
  39.     int lifetime;               /* Lifetime */
  40.     int kvno;                   /* Key version number */
  41.     KTEXT ticket;               /* The ticket itself */
  42.     long issue_date;            /* The issue time */
  43. {
  44.     int tf_status;   /* return values of the tf_util calls */
  45.  
  46.     /* Open and lock the ticket file for writing */
  47.     if ((tf_status = tf_init(TKT_FILE, W_TKT_FIL)) != KSUCCESS)
  48.     return(tf_status);
  49.  
  50.     /* Save credentials by appending to the ticket file */
  51.     tf_status = tf_save_cred(service, instance, realm, session,
  52.                  lifetime, kvno, ticket, issue_date);
  53.     (void) tf_close();
  54.     return (tf_status);
  55. }
  56.